package org.example.struct.array;

/**
 * @author liyishan
 * @date 2024/1/2 10:20
 * @apiNote
 */

public class Test00231IsPowerOfTwo {


    public static boolean isPowerOfTwo(int n) {
        while (n > 1) {
            if (n % 2 != 0) {
                return false;
            }
            n /= 2;
        }
        return n == 1;
    }

    public boolean isPowerOfThree(int n) {
        while(n>1 && n%3==0){
            n/=3;
        }
        return n==1;
    }
}
